package com.tbs.parkingsaleapp.Http.Listenner;

import android.content.Context;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.tbs.parkingsaleapp.Http.HttpHelper;
import com.tbs.parkingsaleapp.Http.IAsycHttpBackgroundAction;
import com.tbs.parkingsaleapp.Http.IAsycHttpResultAction;
import com.tbs.parkingsaleapp.SystemManager.NetWorkSetting;

public class MessageReplyer implements IAsycHttpBackgroundAction<Object,Integer>, IAsycHttpResultAction<Integer> {
    public interface IHandleReuslt
    {
        void Action(int r,int k);
    }

    IHandleReuslt handleReuslt;
    public MessageReplyer(IHandleReuslt handleReuslt)
    {
        this.handleReuslt=handleReuslt;
    }
    int k;
    @Override
    public Integer BackGroundAction(Object... params) throws Exception {
        String obj;
        if(params[1]!=null)
        {
            obj= JSON.toJSONString(params[1]);
        }
        else
            obj="[]";

        String r= HttpHelper.Post(obj, NetWorkSetting.ReplyMessageUrl((Integer)params[0]));
        k=(Integer)params[0];
        return Integer.valueOf(r.trim());
    }

    @Override
    public void ResultFunction(Integer result) {
        handleReuslt.Action(result,k);
    }
}
